<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>中止施工-审批</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/statics/layui/font/font.css" media="all"/>
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <style type="text/css">
        html, body {
            height: 100%;
        }

        .chooseBox {
            border: 1px solid #333;
            height: 300px;
            padding: 10px;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            overflow-y: auto;
        }

        .leftBox > p {
            line-height: 30px;
            padding-left: 20px;
            cursor: pointer;
        }

        .leftBox > p:hover {
            background: #ddd;
        }

        .leftBox > p.selected {
            background: #d5d5d5;
        }

        .hide {
            display: none;
        }
    </style>
</head>
<body>
<div class="layui-fluid" style="height:100%;">
    <form class="layui-form" lay-filter="formData" style="margin-top: 10px;">
        <input type="hidden" name="userId" class="formData">
        <input type="hidden" name="id" class="formData">

        <!--审批内容-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">审批内容</h2>
                <div class="layui-colla-content layui-show">
                    <table class="layui-table v-table">
                        <tbody>
                        <tr class="hide">
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                        </tr>
                        <tr>
                            <td class="th8">申请中止施工时间</td>
                            <td colspan="5">
                                <input name="pauseDate" id="pauseDate" placeholder="中止施工时间" autocomplete="off" class="layui-input formData" lay-verify="required" readonly>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 required">审批意见</td>
                            <td colspan="5" id="spyjtd">
                                <input type="radio"  name="status" value="3" title="同意" lay-filter="spyj" checked class="formData"/>
                                <input type="radio"  name="status" value="2" title="驳回" lay-filter="spyj" class="formData"/>
                            </td>
                        </tr>
                        <tr id="spyj_ty">
                            <td class="th8 required">同意中止施工时间</td>
                            <td colspan="5">
                                <input name="consentPauseDate" id="consentPauseDate" placeholder="中止施工时间" autocomplete="off" class="layui-input formData" lay-verify="required" readonly>
                            </td>
                        </tr>
                        <tr id="spyj_bh" style="display:none">
                            <td class="th8 required">驳回意见</td>
                            <td colspan="5">
                                <textarea name="rejectReason" id="rejectReason" placeholder="请输入驳回意见" class="layui-textarea formData" disabled></textarea>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label required">申请中止施工时间</label>-->
            <!--<div class="layui-input-block">-->
                <!--<input name="pauseDate" id="pauseDate" placeholder="中止施工时间" autocomplete="off" class="layui-input formData" lay-verify="required" readonly>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label required">同意中止施工时间</label>-->
            <!--<div class="layui-input-block">-->
                <!--<input name="consentPauseDate" id="consentPauseDate" placeholder="中止施工时间" autocomplete="off" class="layui-input formData" lay-verify="required" readonly>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label required">驳回意见</label>-->
            <!--<div class="layui-input-block">-->
                <!--<textarea name="rejectReason" placeholder="请输入驳回意见" class="layui-textarea formData"></textarea>-->
            <!--</div>-->
        <!--</div>-->

    </form>
</div>
<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<!--<script type="text/javascript" src="../../../statics/js/sys/editDict.js"  charset="utf-8"></script>-->
<script>
    layui.use(['form', 'sessionFun', 'configure', 'configureCom', 'laydate', 'jquery'], function () {
        window.$ = layui.$;
        var form = layui.form;
        var configure = layui.configure;
        var laydate = layui.laydate;
        var configureCom = layui.configureCom;
        var sessionFun = layui.sessionFun;
        var listData = sessionFun.get(configure.PAUSE_ROW_DATA);
        var token = sessionFun.get(configure.SESSION_TOKEN) ? sessionFun.get(configure.SESSION_TOKEN).token : '';

        form.on('radio(spyj)', function (data) {
            if (data.value == "3") {
                $("#spyj_bh").hide();
                $("#spyj_ty").show();
                $("#consentPauseDate").removeAttr("disabled");
                $("#rejectReason").attr("disabled","disabled");
//                $("#spyjtd input[name=spyj][value=3]").prop("checked",true);
            }else {
                $("#spyj_ty").hide();
                $("#spyj_bh").show();
                $("#rejectReason").removeAttr("disabled");
                $("#consentPauseDate").attr("disabled","disabled");
//                $("#spyjtd input[name=spyj][value=2]").prop("checked",true);
            }
            form.render();
        });

        var pauseId = sessionFun.get('pauseId');
        configureCom.getAjax(configure.PAUSE_DETAIL_INFO,{pauseId:pauseId}).then(function(res){
            if(!res.data){
                res.data = { id: pauseId};
            }
            if(res.data && res.data.status==3){
                $("#spyj_bh").hide();
                $("#spyj_ty").show();
                $("#consentPauseDate").removeAttr("disabled");
                $("#rejectReason").attr("disabled","disabled");
            }else{
                $("#spyj_ty").hide();
                $("#spyj_bh").show();
                $("#rejectReason").removeAttr("disabled");
                $("#consentPauseDate").attr("disabled","disabled");
            }
            form.val('formData', res.data);
        })

        laydate.render({
            elem: '#consentPauseDate',
            type: 'date'
        });

        //详情或修改页面
        if (listData) {
            form.val('formData', listData);
        }
        form.render();
    });

    function getData() {
        return new Promise(function (res, rej) {
            var data = {};
            if (!window.formVerifyFun()) {
                //return false;
            }

            $('.formData').each(function (index, item) {
                var key = $(item).attr('name');
                data[key] = $(item).val();
            });
            data['status'] = $('input[name=status]:checked').val();
            res({result: data});
        });
    }
</script>
</body>
</html>
